<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>promise的新方法</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
  </style>
</head>

<body>
  <div></div>
</body>
<script>
  "use strict"; {
    // promise 提供的新方法了
    const { promise, resolve, reject } = Promise.withResolvers()
    promise.then(() => {
      console.log(`ok`)
    })
    resolve()
  }; {
    // 也可以使用这种方法了
    let resolve
    const promise = new Promise(res => {
      console.log(`好`)
      resolve = res
    })
    promise.then(() => {
      console.log(`res ===`)
    })

    resolve()
  }
</script>

</html>